package main

import "fmt"

// package main
var mem map[int]float64

func main() {
	fmt.Println(myPow(2, 10))
	fmt.Println(mem)
}

func myPow(x float64, n int) float64 {
	mem = make(map[int]float64)
	return helper(x, n)
}

func helper(x float64, n int) float64 {
	if n == 0 {
		return 1
	}
	if value, ok := mem[n]; ok {
		return value
	}
	var res float64
	if n < 0 {
		res = 1 / x * myPow(x, n+1)
	} else {
		res = x * myPow(x, n-1)
	}
	mem[n] = res
	return res
}
